package com.zy.fragment;



import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.View.OnClickListener;


/**
 * @author  lc 
 * @date 创建时间：2016-1-15 下午1:40:27 
 * @version 1.0 
 * @Description
 */
public class BaseFragment extends Fragment implements OnClickListener{
	
	private SharedPreferences defalut_sp;;
	private SharedPreferences appoint_sp;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		defalut_sp= this.getActivity().getSharedPreferences("config", Context.MODE_PRIVATE);
	}
	
	@Override
	public void onResume() {
		super.onResume();
	}

	public void setListener(View... view) {
		for (int i = 0; i < view.length; i++) {
			view[i].setOnClickListener(this);
		}
	}

	@Override
	public void onClick(View v) {
		
	}
	
	
	public String getSharedPreferenceValue(String key) {
		String value = defalut_sp.getString(key, "");
		return value;
	}

	public void putSharedPreferenceValue(String key, String value) {
		SharedPreferences.Editor editor;
		editor = defalut_sp.edit();
		editor.putString(key, value);
		editor.commit();
	}

	public String getSharedPreferenceValue(String tag, String key) {
		appoint_sp = this.getActivity().getSharedPreferences(tag, Context.MODE_PRIVATE);
		String value = appoint_sp.getString(key, "");
		return value;
	}

	public void putSharedPreferenceValue(String tag, String key, String value) {
		appoint_sp = this.getActivity().getSharedPreferences(tag, 0);
		SharedPreferences.Editor editor;
		editor = appoint_sp.edit();
		editor.putString(key, value);
		editor.commit();
	}
}
